import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.render import make_snapshot
from snapshot_phantomjs import snapshot
from io import StringIO

from docx import Document
from docx.shared import Inches
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.shared import Pt






# print(document.paragraphs[5].text)
# text=document.paragraphs[5].text
# print(text)
# document.paragraphs[3].text ：algo name
# document.paragraphs[4].text ：algo name like:"__name__=algo name"
# document.paragraphs[5].text ：code
# document.paragraphs[7].text : result data example
# document.paragraphs[8].text : png

# print( document.paragraphs[5].style.name)
# class doc_control():
#     __document__=None
#     def __init__(self,doc_path):
#         self.__document__ = Document(doc_path)
#
#     def add_algo_title(docu,algo_title):
#         para = docu.paragraphs[3]
#         para.clear()
#         run = para.add_run(text="quick_sort.py")
#         run.font.name = u'宋体'
#         run.font.size = Pt(12)
#
#     def add_algo_code(docu,algo_code=False):
#         para = document.paragraphs[5]
#         para.clear()
#         code_text=[]
#         f=open('D:\Work\Project\Python\Algorithm\sorts\quick_sort.py','r',encoding='utf-8')
#         code_text=f.read()
#         f.close()
#         code_text.replace('\r' or '\n' ,'<w:cr/>' )
#         code_text.replace("\t",'<w:tab/>')
#         run = para.add_run(text=code_text)
#         run.font.name = u'Consolas'
#         run.font.size = Pt(12)
#
#     def add_png(docu,png):
#         para=docu.paragraphs[8]
#         run=para.add_run()
#         run.add_picture(png,width=Inches(4.5))
#         para.paragraph_format.alignment=WD_PARAGRAPH_ALIGNMENT.LEFT
#
#
#     def add_code_result(docu,IOString):
#         # IOString=StringIO()
#         para= document.paragraphs[7]
#         for line in IOString.readlines():
#             run=para.add_run(line)
#         IOString.close()



# document = Document("D:\Work\Project\Python\Algorithm\doc_report\（3） 冒泡排序.docx")
# print(document.paragraphs[7].text)
# text=u''
# text=[]
# text.append(u' 1000  1.001596450805664')
# text.append(u'\n     2000  2.9921531677246094')
# document.save("D:\Work\Project\Python\Algorithm\doc_report\（3） 冒泡排序-1.docx")


# if __name__ == '__main__':
#     document = Document("D:\Work\Project\Python\Algorithm\doc_report\（3） 冒泡排序.docx")
#     add_algo_code(docu=document)
#     document.save("D:\Work\Project\Python\Algorithm\doc_report\（3） 冒泡排序-1.docx")

path="D:\Work\Project\Python\Algorithm\doc_report\（3） 冒泡排序-1.docx"
path=path.split("（")
path.pop()
print(path[0])